var mongoose = require('../common/db');

var mail = new mongoose.Schema({
    fromUser: String,
    toUser: String,
    title: String,
    context: String
}, { versionKey: false } //去除mongoose的__v字段
)
mail.statics.findByToUserId = function (user_id, callBack) {
    this.find({ toUser: user_id }, callBack);
};
mail.statics.findByFromUserId = function (user_id, callBack) {
    this.find({ fromUser: user_id }, callBack);
};

var mailModel = mongoose.model('mail', mail);

module.exports = mailModel